<div class="navbar navbar-default" id="navbar">
    <script type="text/javascript">
        try {
            ace.settings.check('navbar', 'fixed')
        } catch (e) {
        }
    </script>

    <div class="navbar-container" id="navbar-container">
        <div class="navbar-header pull-left">
            <a href="#" class="navbar-brand">
                <small>
                    <i class="icon-leaf"></i>
                    PhotoBox管理平台
                </small>
            </a><!-- /.brand -->
        </div><!-- /.navbar-header -->

        <div class="navbar-header pull-right" role="navigation">
            <ul class="nav ace-nav">
                <li class="light-blue">
                    <a data-toggle="dropdown" href="#" class="dropdown-toggle">
                        <img class="nav-user-photo" src="${resource(dir: 'assets/avatars', file: 'user.jpg')}" alt="Jason's Photo"/>
                        <span class="user-info">
                            <small>欢迎,</small>
                            ${session.user?.username}
                        </span>

                        <i class="icon-caret-down"></i>
                    </a>
                    <ul class="user-menu pull-right dropdown-menu dropdown-yellow dropdown-caret dropdown-close">
                        <li>
                            <a id="btnLogin" href="javascript: void(0);"> <i class="icon-off"></i>重新登录</a>
                        </li>
                        <li>
                            <g:link controller="mngHome" action="adminQuit">
                                <i class="icon-off"></i>
                                注销
                            </g:link>
                        </li>
                    </ul>
                </li>
            </ul><!-- /.ace-nav -->
        </div><!-- /.navbar-header -->
        <r:script>
            (function($){
                var content = [
                    "<form class='loginForm'>",
                    "<table>",
                    "   <tr>",
                    "       <td cols='2'>",
                    "           <div class='msg'>请输入用户名和密码</div>",
                    "       </td>",
                    "   </tr>",
                    "   <tr>",
                    "       <td>用户名：</td>",
                    "       <td>",
                    "           <input type='text' name='username' />",
                    "       </td>",
                    "   </tr>",
                    "   <tr>",
                    "       <td>密 码：</td>",
                    "       <td>",
                    "           <input type='password' name='password' />",
                    "       </td>",
                    "   </tr>",
                    "</table>",
                    "</form>"
                ];
                $("#btnLogin").click(function() {
                    var dialog = bootboxExt.dialog({
                        width: 300, height: 300,
                        url: "<g:createLink controller='auth' action='loginForm'/>",
                        message: content.join("\n"),
                        buttons: {
                            success: {
                                label: "登录",
                                className: "btn-success",
                                callback: function() {
                                    var loginForm = $(".loginForm", dialog);
                                    $(".msg", dialog).html("正在登录...");
                                    var data = {};
                                    $("input", loginForm).each(function(idx, el) {
                                        if (el.name) {
                                            data[el.name] = $(el).val();
                                        }
                                    });
                                    $.post("<g:createLink controller='auth' action='signIn' params="[format: 'json']"/>", data, function(data, success, req) {
                                        if (success === "success") {
                                            $(".msg", dialog).html(data.message);
                                            if (data.code == 0) {
                                                dialog.modal("hide");
                                            }
                                        }
                                    });
                                    return false;
                                }
                            },
                            cancel: {
                                label: "取消",
                                className: "btn",
                                callback: function() {
                                    return true;
                                }
                            }
                        }
                    });
                });
            }(jQuery));
        </r:script>
    </div><!-- /.container -->
</div>